﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spaanjaars.ContactManager.Infrastructure.UnitOfWork;
using Spaanjaars.ContactManager.Model;
using Spaanjaars.ContactManager.Services.Interfaces;
using Spaanjaars.ContactManager.Services.Mappers;
using Spaanjaars.ContactManager.Services.Queries;
using Spaanjaars.ContactManager.Services.ViewModels;

namespace Spaanjaars.ContactManager.Services.Implementations
{
    public class ContactPersonSearchService : IContactPersonSearchService
    {
        private readonly IContactPersonRepository _contactPersonRepository;
        private readonly IUnitOfWork _unitOfWork;

        public ContactPersonSearchService(IContactPersonRepository contactPersonRepository, IUnitOfWork unitOfWork)
        {
            _contactPersonRepository = contactPersonRepository;
            _unitOfWork = unitOfWork;
        }

        public IEnumerable<ContactPersonViewModel> FindPeople(FindPeopleQuery findPeopleQuery)
        {
            return _contactPersonRepository.FindAll(findPeopleQuery.PageIndex, findPeopleQuery.PageCount).ConvertAllToContactPersonViewModel(findPeopleQuery.LoadContactPersonAddresses);            
        }
    }
}
